
$('#reseller').datagrid({
				title:'List Reseller',
				//iconCls:'icon-ok',
				width:'auto',
				height:tinggi-225,
				nowrap: true,
				autoRowHeight: false,
				singleSelect:true,
				striped: true,
				collapsible:false,
				url: host+'backend/get_data/tbl_user/all',
				pagination:"true",
				queryParams:{
					
				},
				
			toolbar:[
					 {
						text:'Delete',
						iconCls:'delete',
						handler:function(){
							cek_grid('delete','Hapus');
						}
					 },'-',
					  {
						text:'Set Non Aktif/Aktif',
						iconCls:'accept',
						handler:function(){
							cek_grid('non','Hapus');
						}
					 }
				
			],	
			frozenColumns:[[
				{field:'ck', checkbox:true},
				{field:'status_user' ,title:'Status', width:100, sortable:true,
					styler:function(index,rowData){  
						if(rowData.status_user =='1'){
							return 'background-color:#64B7DE';  
						}
						else{return 'background-color:#E9594D';}
					},
					formatter:function(value,rowData,rowIndex){
						if(rowData.status_user == '1'){
							return 'Aktif'
						}
						else{
							return 'Tidak Aktif'	
						}
					}
				},
				{field:'user_id' ,title:'UserID', width:150, sortable:true},
				{field:'nama_group' ,title:'Group Reseller', width:100, sortable:true},
				{field:'nama_lengkap' ,title:'Nama Lengkap', width:150, sortable:true},
			]],
				columns:[[
					
					{field:'email' ,title:'Email', width:150, sortable:true,align:'left'},
					{field:'alamat' ,title:'Alamat', width:200, sortable:true},
					{field:'telp' ,title:'Telp', width:150, sortable:true},
					{field:'hp' ,title:'HP', width:150, sortable:true},
					{field:'tgl_buat',title:'Gabung TGL', width:150, sortable:true},
					
				]]
});

function cek_grid(tbl,jdl){
		row = $('#reseller').datagrid('getSelected');
		if(row){
			if(tbl=='delete'){
				$.messager.confirm('Confirm','Yakin Data Produk Ini Akan Dihapus ?',function(r){  
					if (r==true){  
					  	$.post(host+'backend/hapus/tbl_user',{id:row.user_id},function(resp){
							if(resp==1){$.messager.alert("Data","Data Sudah Terhapus",'info');$('#reseller').datagrid('reload');}		   
						});	
					}  
				}); 
			}
			else{
				var statusna;
				if(row.status_user=='1'){statusna='2';}else{statusna='1';}
				$.post(host+'backend/simpan/tbl_user',{sts:'edit',id:row.user_id,status_user:statusna},function(resp){
					var r=eval('(' + resp + ')');
					if(r.msg==1){$.messager.alert("Data","Aktivasi / Non Aktivasi Berhasil",'info');$('#reseller').datagrid('reload');}		   
				});		
			}
			
		}
		else{$.messager.alert("Data","Pilih Salah Satu Data",'error');}
}